// 样式标准化
import 'reseter.css/css/reseter.min.css'

import { createApp } from 'vue'
import App from './App.vue'
import { setupStore } from './store'
import router, { setupRouter } from './router'

// element
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 配合 vite-plugin-svg-icons，处理 svgIcon
import 'virtual:svg-icons-register'

// 全局样式
import './styles/index.less'

async function bootstrap() {
  const app = createApp(App)

  // 挂载状态管理
  setupStore(app)

  // 挂载路由
  setupRouter(app)
  // 等待路由准备就绪
  await router.isReady()

  // 全局注册 ele-plus
  app.use(ElementPlus, {
    locale: zhCn
  })
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }

  app.mount('#app')
}
void bootstrap()
